// pages/todo/todo.js
Page({
  /**
   * 页面的初始数据
   */
  data: {
    value: '',
    todoList: []
  },
  clear(event) {
    const list = this.data.todoList
    
    this.setData({
      todoList: list.filter(item=>item !== event.mark.item)
    })
  },
  allClear() {
    this.setData({
      todoList: [],
      value: ''
    })
  },
  shuru() {
    if (this.data.value == '' || this.data.value.trim() == '') {
      return wx.showToast({
        title: '不能为空',
      })
    } else if (this.data.todoList.includes(this.data.value)) {
      return wx.showToast({
        title: '不能重复',
      })
    }
    else {
      const list = this.data.todoList
      list.push(this.data.value)
      this.setData({
        todoList: list,
        value: ''
      })
    }
  }

})
